import { actionTypes } from "./index";
import { fromJS } from 'immutable'

const defaultState = fromJS({
    focused : false,
    mouseIn : false,
    list: [],
    page: 1,
    totalPage: 0
})
export default (state = defaultState,action)=>{
    switch (action.type) {
        case actionTypes.CHANGE_FOCUS_STATUS:
            return state.set('focused',action.value)

        case actionTypes.CHANGE_HOT_LIST:
            return state.set('list',action.value)

        case actionTypes.MOUSE_ENTER:
            return state.set('mouseIn',true)

        case actionTypes.MOUSE_LEAVE:
            return state.set('mouseIn',false)

        case actionTypes.CHANGE_PAGE:
            if( action.page <5){
                return state.set('page',action.page +1)
            }else{
                return state.set('page',1)
            }

        default:
            return state
    }

}
